package cz.gelion.shylock.invoice.entity

import javax.persistence.Entity
import javax.persistence.Table
import scala.beans.BeanProperty
import javax.persistence.Column
import javax.persistence.ManyToOne
import javax.persistence.JoinColumn
import javax.persistence.OneToMany
import javax.persistence.Temporal
import java.util.Calendar
import javax.persistence.TemporalType
import javax.persistence.Id
import javax.persistence.GeneratedValue
import cz.gelion.shylock.invoice.ManagedInfo
import javax.persistence.PreUpdate
import javax.persistence.PrePersist
import cz.gelion.shylock.invoice.Log



@Entity
@Table(name="account")
class Account extends ManagedInfo {
  
  def this(s:Subject) = {
    this
    subject = s
  }
  
  import Account._
  
  
  @BeanProperty
  @Id
  @GeneratedValue
  @Column(name="id")
  var id:Int = _
  
  @BeanProperty
  @ManyToOne
  @JoinColumn(name="subject")
  var subject:Subject = _
  
  @BeanProperty
  @Column(name="account_no")
  var accountNo:String = _
  
  @BeanProperty
  @Column(name="note")
  var note:String = _ 
  
  @BeanProperty
  @ManyToOne
  @JoinColumn(name="muser")
  var manager:Manager = _
  
  @BeanProperty
  @Column(name="mtime")
  @Temporal(TemporalType.TIMESTAMP)
  var mtime:Calendar = _
  
   
  @PreUpdate
  @PrePersist
  def preUpdate = {
    stamp
  }
  
  
}

object Account extends Log
